﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Threading;
using System.Collections.ObjectModel;

namespace gui {

    /// <summary>
    /// GUI Notifiable FactoryList Class
    /// Contains an observable collection of factoryItems
    /// </summary>
    public class FactorySelectListInfo : DependencyObject {

        public static FactorySelectListInfo Instance;
        public static Dispatcher _Dispatcher { get; set; }

        public static DependencyProperty FactoriesListProperty = DependencyProperty.Register("FactoriesList", typeof(ObservableCollection<FactoryItem>), typeof(FactorySelectListInfo));

        static FactorySelectListInfo() {
            Instance = new FactorySelectListInfo();
        }

        public ObservableCollection<FactoryItem> FactoriesList {
            get { return (ObservableCollection<FactoryItem>)GetValue(FactoriesListProperty); }
            set { SetValue(FactoriesListProperty, value); }
        }

        public static void Clear() {
            if (_Dispatcher != null) {
                _Dispatcher.BeginInvoke(
                    DispatcherPriority.Send,
                    new Action(delegate() {
                        Instance.FactoriesList.Clear();
                }));
            }
        }
    }
}
